//
//  main.m
//  NSDictionary字典
//
//  Created by mir_yan on 2018/10/1.
//  Copyright © 2018年 hakeem. All rights reserved.
//

/**
 NSDictionary 键值编码 无序 key-value
 key 唯一
 
 */
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // 前value 后 key
        NSDictionary* dect = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil];
        NSLog(@"%@", dect);

        NSDictionary * dect3 =
        @{@"key1":@"value1", @"key2":@"value2"};
        NSLog(@"%@", dect3);
        
        NSLog(@"%@", [dect3 objectForKey:@"key2"]);
        NSLog(@"%@", dect3[@"key2"]);
        
        // 打印key value
        for (NSString* string in dect3) {
            NSLog(@"%@ %@", string, dect3[string]);
        }
        
        NSArray* arr = [dect3 allValues];
        NSLog(@"%@", arr);
        
        // 初始化空的字典
        NSMutableDictionary * dictEMY = [NSMutableDictionary dictionary];
        dictEMY[@"key1"] = @"value1";
        NSLog(@"%@", dictEMY);
        // 移除
        [dictEMY removeObjectsForKeys:@[@"key1"]];
        NSLog(@"%@", dictEMY);
        
    }
    return 0;
}
